/*     */ package dm.jdbc.dbaccess;
/*     */ 
/*     */ import java.io.IOException;
/*     */ import java.lang.reflect.Constructor;
/*     */ import java.lang.reflect.Method;
/*     */ import java.net.Socket;
/*     */ import java.net.SocketException;
/*     */ import java.util.ResourceBundle;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ public class StandardSocketFactory
/*     */   implements SocketFactory
/*     */ {
/*  25 */   protected Socket rawSocket = null;
/*     */   
/*     */ 
/*  28 */   protected String host = null;
/*     */   
/*     */ 
/*  31 */   protected int port = 0;
/*     */   
/*     */ 
/*  34 */   protected int connectTimeout = 0;
/*     */   
/*  36 */   private final ResourceBundle res = Const.res;
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public Socket afterHandshake()
/*     */     throws SocketException, IOException
/*     */   {
/*  53 */     return this.rawSocket;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public Socket beforeHandshake()
/*     */     throws SocketException, IOException
/*     */   {
/*  68 */     return this.rawSocket;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public Socket connect(String hostStr, String portStr, int timeout)
/*     */     throws SocketException, IOException
/*     */   {
/*  84 */     this.host = hostStr;
/*     */     
/*  86 */     if (portStr != null) {
/*  87 */       this.port = Integer.parseInt(portStr);
/*     */     }
/*     */     
/*  90 */     boolean hasConnectTimeoutMethod = false;
/*     */     
/*  92 */     Method connectWithTimeoutMethod = null;
/*     */     
/*     */     try
/*     */     {
/*  96 */       Class socketAddressClass = Class.forName("java.net.SocketAddress");
/*     */       
/*  98 */       connectWithTimeoutMethod = tmp33_30.getMethod("connect", 
/*  99 */         new Class[] { socketAddressClass, Integer.TYPE });
/*     */       
/* 101 */       hasConnectTimeoutMethod = true;
/*     */     } catch (NoClassDefFoundError noClassDefFound) {
/* 103 */       hasConnectTimeoutMethod = false;
/*     */     } catch (NoSuchMethodException noSuchMethodEx) {
/* 105 */       hasConnectTimeoutMethod = false;
/*     */     } catch (Throwable catchAll) {
/* 107 */       hasConnectTimeoutMethod = false;
/*     */     }
/*     */     
/* 110 */     this.connectTimeout = timeout;
/*     */     
/* 112 */     if (this.host != null) {
/* 113 */       if ((!hasConnectTimeoutMethod) || (this.connectTimeout == 0)) {
/* 114 */         this.rawSocket = new Socket(this.host, this.port);
/*     */       }
/*     */       else {
/*     */         try
/*     */         {
/* 119 */           Class inetSocketAddressClass = 
/* 120 */             Class.forName("java.net.InetSocketAddress");
/* 121 */           Constructor addrConstructor = inetSocketAddressClass
/* 122 */             .getConstructor(new Class[] { String.class, 
/* 123 */             Integer.TYPE });
/*     */           
/* 125 */           Object sockAddr = addrConstructor.newInstance(new Object[] {
/* 126 */             this.host, new Integer(this.port) });
/*     */           
/* 128 */           this.rawSocket = new Socket();
/* 129 */           connectWithTimeoutMethod.invoke(this.rawSocket, new Object[] {
/* 130 */             sockAddr, new Integer(this.connectTimeout) });
/*     */         } catch (Throwable t) {
/* 132 */           throw new SocketException(t.toString());
/*     */         }
/*     */       }
/*     */       try
/*     */       {
/* 137 */         this.rawSocket.setTcpNoDelay(true);
/*     */       }
/*     */       catch (Exception localException) {}
/*     */       
/*     */ 
/* 142 */       return this.rawSocket;
/*     */     }
/*     */     
/* 145 */     throw new SocketException(this.res.getString("error.socket.create"));
/*     */   }
/*     */ }


/* Location:              D:\Program Files\DBMS_20150813\jdbc\Dm7JdbcDriver17.jar!\dm\jdbc\dbaccess\StandardSocketFactory.class
 * Java compiler version: 2 (46.0)
 * JD-Core Version:       0.7.1
 */